/**
 * Live GPS Tracking Application
 * Splits a string and returns it part-by-part
 *
 * Copyright 2009, Ivar Clemens
 */

package nl.ivarclemens;

public class StringTokenizer {
    private String str;
    private char delim;

    public StringTokenizer(String str, char delim)
    {
        this.str = str;
        this.delim = delim;
    }

    public boolean hasToken()
    {
        return !(str.compareTo("") == 0);
    }

    public String nextToken()
    {
        int delimPos = str.indexOf(delim);

        if(delimPos >= 0) {
            String token = str.substring(0, delimPos);
            str = str.substring(delimPos + 1);

            return token;
        } else {
            String token = str;
            str = "";
            
            return token;
        }
    }
}
